package com.xiaozhu.common.list;

import android.os.Handler;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.xiaozhu.common.R;
import com.xiaozhu.common.list.adapters.ListAdapter;
import com.xiaozhu.library.activity.BaseRecyclerActivity;
import com.xiaozhu.library.adapters.BaseRecyclerAdapter;
import com.xiaozhu.library.entity.BaseEntity;
import com.xiaozhu.library.entity.EventBusEntity;

/**
 * @说明
 * @作者 LY
 * @时间 2017/12/20 15:14
 * @邮箱 2743569843@qq.com
 * @版权 Copyright(c) 2017 LY-版权所有
 * @备注
 */
public class ListActivity extends BaseRecyclerActivity<BaseEntity> {
    @Override
    public void initView() {
        super.initView();
        titleBar.setTitle("列表");
        titleBar.setBtnLeft(R.mipmap.icon_back, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    @Override
    public void business() {
        startRefresh();
    }

    @Override
    public void loadingData() {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 30; i++) {
                    adapter.addObject(new BaseEntity());
                }
                stopRefresh();
            }
        }, 3000);
    }

    @Override
    public void itemClick(Object o, int position) {

    }

    @Override
    public BaseRecyclerAdapter getAdapter() {
        return new ListAdapter(this);
    }

    @Override
    public RecyclerView.LayoutManager getLayoutManager() {
        return new LinearLayoutManager(this);
    }
}

